//
//  Enemy.m
//  BeatPlane
//
//  Created by qianfeng on 15-5-6.
//  Copyright (c) 2015年 韩世民. All rights reserved.
//

#import "Enemy.h"
#define kScreenSize [UIScreen mainScreen].bounds.size
#define kEnemySpeed 1
@implementation Enemy

-(instancetype)init{
    if (self = [super init]) {
        self.image = [UIImage imageNamed:@"plane.png"];
        [self resetFrame];
    }
    return self;
}
-(void)moveDown{
    CGRect frame = self.frame;
    if (frame.origin.y > kScreenSize.height) {
        [self resetFrame];
        
    }else{
        frame.origin.y+=kEnemySpeed;
        self.frame =frame;
    }
}

-(void)resetFrame{
    //随机产生坐标
    NSInteger sub = kScreenSize.width-50;
    CGFloat y =-(arc4random()%50+50.0);
    self.frame = CGRectMake(arc4random( )%sub, y, 50, 50);
}
    

@end
